<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>主页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<script type="text/javascript">
	function validate() {
		var page = document.getElementsByName("page")[0].value;
		if (page > <s:property value="pageBean.totalPage"/>) {
			alert("你输入的页数大于最大页数，页面将跳转到首页！");
			window.document.location.href = "globalAction";
			return false;
		}
		return true;
	}
</script>

</head>
<body>
	<h1>
		<font color="blue">分页查询</font>
	</h1>
	<h1>
		<s:if test="#session.username != null">
			<h2>
				欢迎您,
				<s:property value="#session.username" />
				&nbsp; <a href="user_logout">退出登录</a>
			</h2>
		</s:if>
		<s:else>
			<a href="index.jsp">登录/注册</a>
		</s:else>
	</h1>
	<hr>

	<table border="1" bordercolor="yellow" width="50%">
		<tr>
			<th>书名</th>
			<th>联系方式</th>
			<th>图片</th>
		</tr>
		<s:iterator value="pageBean.list" id="book">
			<tr>
				<th><s:property value="#book.bookname" /></th>
				<th><s:property value="#book.phone" /></th>
				<th><img alt="" src="<s:property value="#book.url" />"
					width="100px" height="100px" /></th>

			</tr>
		</s:iterator>
	</table>
	<font size="5">共<font color="red"><s:property
				value="pageBean.totalPage" /></font>页
	</font>&nbsp;&nbsp;
	<font size="5">共<font color="red"><s:property
				value="pageBean.allRows" /></font>条记录
	</font>
	<br>
	<br>

	<s:if test="pageBean.currentPage == 1">
            首页&nbsp;&nbsp;&nbsp;上一页
        </s:if>

	<s:else>
		<a href="globalAction">首页</a>
            &nbsp;&nbsp;&nbsp;
            <a
			href="allBook?page=<s:property value="pageBean.currentPage - 1"/>">上一页</a>
	</s:else>

	<s:if test="pageBean.currentPage != pageBean.totalPage">
		<a
			href="allBook.action?page=<s:property value="pageBean.currentPage + 1"/>">下一页</a>
            &nbsp;&nbsp;&nbsp;
            <a
			href="allBook?page=<s:property value="pageBean.totalPage"/>">尾页</a>
	</s:if>

	<s:else>
            下一页&nbsp;&nbsp;&nbsp;尾页 &nbsp;
        </s:else>
	&nbsp;&nbsp;当前在第
	<font color="red"><s:property value="page" /></font>页
	<br>
	<form action="allBook" onsubmit="return validate();">
		<font size="4">跳转至</font> <input type="text" size="2" name="page">页
		<input type="submit" value="跳转">
	</form>
	
	<s:form action="addBook" method="post" enctype="multipart/form-data">
		<table align="center" width="50%" border="0">
			<tr>
				<s:textfield name="bookname" label="书名" required=""></s:textfield>
			</tr>
			<tr>
				<s:textfield name="edition" label="出版社"></s:textfield>
			</tr>
			<tr>
				<s:textfield name="author" label="作者" required=""></s:textfield>
			</tr>
			<tr>
				<s:textfield name="price" label="价格" required=""></s:textfield>
			</tr>
			<tr>
				<s:textfield name="description" label="书籍描述"></s:textfield>
			</tr>
			<tr>
				<s:textfield name="phone" label="联系方式" required=""></s:textfield>
			</tr>
			<tr>
				<s:file name="file" label="上传图片"></s:file>
			</tr>
			<tr>
				<s:submit value="submit"></s:submit>
			</tr>
		</table>
	</s:form>




	<s:debug></s:debug>
</body>
</html>